//
//  LBShowCurrentScoreAnimationDelegate.m
//  LittleBall
//
//  Created by apple on 11-11-20.
//  Copyright (c) 2011年 __MyCompanyName__. All rights reserved.
//

#import "LBShowCurrentScoreAnimationDelegate.h"
#import "LittleBallViewController.h"


@implementation LBShowCurrentScoreAnimationDelegate

@synthesize m_owner;

-(id)initWithScore:(int)score withLabel:(UILabel *)label owner:(id)owner;
{
    //[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
    
    if( !(self = [super init]))
    {
        return nil;
    }
    
    m_currentScoreLabel = label;
    m_score = score;
    m_owner = owner;
    
    [m_currentScoreLabel setHidden:FALSE];
    
    NSString *scoreStr = [[NSString alloc] initWithFormat:@"%d",m_score];
    [m_currentScoreLabel setText:scoreStr];
    
    [UIView beginAnimations:nil context:NULL];
    
    [UIView setAnimationDelegate:self];
    
    [UIView setAnimationRepeatCount:1];
    [UIView setAnimationDuration:SCORE_LABEL_MOVE_SPEED];
    
    CGAffineTransform transform = CGAffineTransformMakeScale(1.5, 1.5);
    m_currentScoreLabel.transform = transform;
    m_currentScoreLabel.alpha = 0;

    [UIView commitAnimations];
    
    return self;
}

- (void)animationWillStart:(NSString *)animationID context:(void *)context
{
    // do nothing...    
}

- (void)animationDidStop:(NSString *)animationID finished: (NSNumber *)finished context:(void *)context
{
    [m_currentScoreLabel setHidden:TRUE];

    CGAffineTransform transform = CGAffineTransformMakeScale(1, 1);
    m_currentScoreLabel.transform = transform;
    m_currentScoreLabel.alpha = 1;
}

@end
